package com.godyao.mall.seckill.service;

import com.godyao.mall.core.model.ResultMsg;
import com.godyao.mall.seckill.model.SeckillActivity;
import com.godyao.mall.seckill.model.response.SeckillActivityResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

/**
 * @author godyao
 * @date 2022/4/1
 */
public interface ISeckillService {
    SeckillActivity save(SeckillActivity seckillActivity);

    void del(Long id);

    Page<SeckillActivityResponse> findFrontAll(Specification specification, Pageable pageable);

    /**
     * 校验code合法性
     * @param code
     * @param goodsId
     * @return
     */
    boolean checkUrlCode(String code, Long goodsId);

    /**
     * 秒杀购买
     * @param goodsId
     * @return
     */
    ResultMsg buy(Long goodsId);

    /**
     * 根据goodsId和userId生成秒杀code 构成秒杀地址
     * @return
     */
    String generateSecKillCode(Long goodsId);

}
